<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>代理设备列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" type="text/css" href="css/main.css" />
  <link rel="stylesheet" type="text/css" href="../mobile/js/layer/css/layui.css" />
  <script src="../mobile/js/jquery-1.9.1.js"></script>
  <script src="../mobile/js/layer/layui.js"></script>
  <script src="./js/common.js"></script>
  <script type="text/javascript">
      //访问是否登录,ajax同步请求
      logins(); 
  </script>
  <style type="text/css">
    .layui-table-cell{
      height: 50px;
      line-height: 50px;
    }
  </style>
</head>
<body>
<div style="margin: -30px 20px 20px 20px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>代理设备列表</legend>
</fieldset>
<blockquote class="layui-elem-quote">
      <button class="layui-btn" style="background:#5FB878;" onclick="javascript :history.back(-1);"><i class="layui-icon" style="color: #fff">&#xe65c;</i>返回</button>
        <div class="layui-inline">
            <input class="layui-input" name="key" id="key" placeholder="请输入设备号">
        </div>&nbsp;
	   <button class="layui-btn btns" id="search" data-type="reload"><i class="layui-icon" style="color: #fff">&#xe615;</i>搜索</button>
	   <!-- <button class="layui-btn" style="border: 1px solid #35C4F9;background: none;color:#35C4F9"><i class="layui-icon" style="color: #35C4F9">&#xe641;</i>导出设备</button> -->
	   <button class="layui-btn" style="border: 1px solid #35C4F9;background: none;color:#35C4F9"><i class="layui-icon" style="color: #35C4F9">&#xe641;</i><span id="counts" style="color:red;"></span></button>
	   <!-- <button class="layui-btn btns_del" id="delAll"><i class="layui-icon" style="color: #fff">&#xe640;</i>批量删除</button> -->
</blockquote>
<table class="layui-hide" id="list" lay-filter="list"></table>
</div>
<!-- <script type="text/html" id="status">
    {{# if(d.status==1){ }}
       <input type="checkbox" name="status" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" checked value="{{d.id}}">
    {{# }else{  }}
       <input type="checkbox" name="status" lay-skin="switch" lay-filter="status" lay-text="开启|关闭" value="{{d.id}}">
    {{# } }}
</script> -->
<!-- <script type="text/html" id="code">
    	<img width="50" height="50" src="{{d.QRcode}}">
</script> -->
<script type="text/html" id="action">
    <a href="user_id={{d.user_id}}" title="编辑"><i class="layui-icon" style="color: #5FB878;font-size: 25px;">&#xe642;</i></a>
    <a lay-event="del" title="删除"><i class="layui-icon" style="color:#FF5722;font-size: 25px;">&#xe640;</i></a>
</script>
<script>
var id = new Object();
id = GetRequest();
layui.use(['table','form'], function() {
      var table = layui.table,form = layui.form,$ = layui.jquery;
      var urls = url + "/admin/agency/daili_details";
      var tableIn = table.render({
          elem: '#list',
          url: urls,
          method: 'post',
          page: true,
          where: {daili_id:id.daili_id},
          cols: [[
              // {checkbox:true,fixed: true},
              {field: 'device_id', title: '编号', fixed: true,width:100,align: 'center', },
              {field: 'dengji', title: '等级',width:200,align: 'center', },
              {field: 'agent_name', title: '代理商',width:200,align: 'center', },
              {field: 'device_sn', title: '设备号',width:300,align: 'center', },
              {field: 'yongjin1', title: '一级佣金比例',width:161,align: 'center',},
              {field: 'yongjin2', title: '二级佣金比例',width:161,align: 'center',},
              {field: 'yongjin3', title: '三级佣金比例',width:161,align: 'center',},
              {field: 'yongjin4', title: '四级佣金比例',width:161,align: 'center',},
              {field: 'addtime', title: '日期',width:200,align: 'center', },
              // {field: 'DeviceSecret', title: 'DeviceSecret',align: 'center',},
              // {title: 'QRcode', width: 160, align: 'center', toolbar: '#code'},
            /*  {title: '启用状态',width:100, align: 'center', toolbar: '#status'},*/
              // {title: '操作', width: 160, align: 'center', toolbar: '#action'}
          ]],
          limit: 10,
          done : function(res, curr, count){
            console.log(res);
          	$('#counts').html('总计数量：'+res.num);
            hoverOpenImg();//显示大图
            $('table tr').on('click',function(){
                 $('table tr').css('background','');
                 $(this).css('background','<%=PropKit.use("config.properties").get("table_color")%>');
            });
            if (res.codes == 0) {
                layer.alert(res.infomsg,{time:1000,icon:5});
            }
          }
      });
       
      //图片放大
      function hoverOpenImg(){
        var img_show = null; // tips提示
        $('td img').hover(function(){
            var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='width:130px;padding:10px 5px;' />";
            img_show = layer.tips(img, this,{
                tips:[2, 'rgba(41,41,41,.5)']
                ,area: ['170px']
            });
        },function(){
            layer.close(img_show);
        });
        $('td img').attr('style','max-width:70px');
      }

     /* //修改状态
      form.on('switch(status)', function(obj){
            var urls = "/admin/config/status";
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var status = obj.elem.checked===true?1:0;
            $.post(urls,{'id':id,'status':status},function(msg) {
                  layer.close(loading);
                  var msg = JSON.parse(msg);
                  if(msg.code == 1){
                      layer.msg(msg.infomsg,{time:1000,icon:6});
                      tableIn.reload();
                  }else{
                      layer.msg(msg.infomsg,{time:1000,icon:5});
                }
            });
      });*/
      
      //单条记录删除
      // table.on('tool(list)', function(obj) {
      //       var urls = "/admin/userlist/delusers";
      //       var data = obj.data;
      //       if (obj.event === 'del') {
      //           layer.confirm('您确定要删除该记录吗？', function(index){
      //               var loading = layer.load(1, {shade: [0.1, '#fff']});
      //               $.post(urls,{user_id:data.user_id},function(msg){
      //                   layer.close(loading);
      //                   var msg = JSON.parse(msg);
      //                   if(msg.code == 1){
      //                       layer.msg(msg.infomsg,{time:1000,icon:6});
      //                       tableIn.reload();
      //                   }else{
      //                       layer.msg(msg.infomsg,{time:1000,icon:5});
      //                   }
      //               });
      //               layer.close(index);
      //           });
      //       }
      //   });

      // //批量删除
      // $("#delAll").click(function(){
      //     var urls = "/admin/userlist/delallusers";
      //     layer.confirm('确认要删除选中信息吗？',{icon: 3},function(index) {
      //       layer.close(index);
      //       var checkStatus = table.checkStatus('list'); //test即为参数id设定的值
      //       var ids = [];
      //       $(checkStatus.data).each(function (i, o) {
      //           ids.push(o.user_id);
      //       });
      //       var loading = layer.load(1, {shade: [0.1, '#fff']});
      //       $.post(urls,{user_id:ids},function(msg){
      //           layer.close(loading);
      //           var msg = JSON.parse(msg);
      //           if (msg.code == 1) {
      //               layer.msg(msg.infomsg, {time: 1000, icon: 6});
      //               tableIn.reload();
      //           }else{
      //               layer.msg(msg.infomsg, {time: 1000, icon: 5});
      //           }
      //       });
      //     })
      // });
       
      //搜索内容
      $('#search').on('click', function() {
            var key = $('#key').val();
            if($.trim(key)==='') {
                layer.msg('请输入关键字！',{icon:0});
                return;
            }
            tableIn.reload({
                where: {key: key,daili_id:id.daili_id}
            });
       });
});
</script>
</body>
</html>